<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="<%=request.getContextPath()%>/resource/css/index3.css" rel="stylesheet">
<script type="text/javascript" src="<%=request.getContextPath()%>/resource/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
	function goPage(pageNum) {
		$("[name='pageNum']").val(pageNum);
		$("form").submit();
	}
	function del(id) {
		if(confirm("是否删除"+id)){
			$.post(
				"del",
				{id:id},
				function (msg) {
					if(msg){
						alert("删除成功"),
						location.reload();
					}else{
						alert("删除失败");
					}
				},
				"json"
			)
		}
	}
	function cz() {
		location.href="cz";
	}
	function tz() {
		location.href="tz";
	}
</script>
</head>
<body>
<form action="list" method="post">
	<input type="hidden" name="pageNum">
	小区名称:<input type="text" name="name">
	出租状态:<select name="status">
			<option value="">--请选择--</option>
			<option value="0">待租</option>
			<option value="1">已租</option>
	</select>
	<input type="submit" value="查询">
</form>
	<table>
		<tr>
			<td>编号</td>
			<td>小区名称</td>
			<td>单元楼</td>
			<td>门牌号</td>
			<td>实景图</td>
			<td>状态</td>
			<td>挂牌时间</td>
			<td>出租时间</td>
			<td>户型</td>
			<td>操作</td>
		</tr>
		<c:forEach items="${info.list }" var="ho">
			<tr>
				<td>${ho.id }</td>
				<td>${ho.name }</td>
				<td>${ho.building }</td>
				<td>${ho.number }</td>
				<td>${ho.picture }</td>
				<td>${ho.status==0?'出租':'已租' }</td>
				<td><fmt:formatDate value="${ho.listingTime }" pattern="yyyy-MM-dd"/> </td>
				<td><fmt:formatDate value="${ho.rentalTime }" pattern="yyyy-MM-dd"/> </td>
				<td>${ho.tname }</td>
				<td>
				<c:if test="${ho.status==0 }">
				<input type="button" value="删除" onclick="del(${ho.id })">
				
				<input type="button" value="出租" onclick="cz()">
				</c:if>
				<c:if test="${ho.status==1 }">
				<input type="button" value="退租" onclick="tz()">
				</c:if>
				</td>
			</tr>
		</c:forEach>
		<tr>
			<td colspan="10">
				当前是${info.pageNum }/${info.pages }页，共${info.total }条数据
				<input type="button" value="首页" onclick="goPage(1)">
				<input type="button" value="上一页" onclick="goPage(${info.prePage})">
				<input type="button" value="下一页" onclick="goPage(${info.nextPage})">
				<input type="button" value="尾页" onclick="goPage(${info.pages})">
			</td>
		</tr>
	</table>
</body>
</html>